package com.dr.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dr.domain.User;
import com.dr.mapper.UserMapper;
import com.dr.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: yangjianfeng
 * @Date: 2025/07/04 14:21
 * @Description:  alt+enter
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(String userName, String password) {
        //1  根据用户名查询当前用户名是否存在
       User user=   userMapper.findUserByUserName(userName);
       if(user==null){
          throw   new RuntimeException("用户名不存在");
       }

        //2  判断密码是否正确
        if(!user.getPassword().equals(password)){
           throw   new RuntimeException("密码错误");
        }
        return user;
    }
}
